-
Notifications
You must be signed in to change notification settings - Fork 129
Raise explicitly on Python methods that are incompatible with lazy variables #1190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Raise explicitly on Python methods that are incompatible with lazy variables #1190
Conversation
4e47797
to
457be84
Compare
fb92728
to
c051841
Compare
Codecov ReportAttention: Patch coverage is
❌ Your patch status has failed because the patch coverage (82.53%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #1190 +/- ##
==========================================
- Coverage 82.01% 81.99% -0.02%
==========================================
Files 188 188
Lines 48561 48566 +5
Branches 8679 8677 -2
==========================================
- Hits 39826 39823 -3
- Misses 6572 6580 +8
Partials 2163 2163
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can remove lines 779:783 of pytensor/scalar/basic.py
, otherwise that looks good to me
…riables Notably changes the behavior of `__bool__` to always raise. Before there was a hack based on whether a variable had been compared to something before.
c051841
to
04a6785
Compare
Thanks, removed them |
Notably changes the behavior of
__bool__
to always raise. Before there was a hack based on whether a variable had been compared to something before.This should avoid surprising behavior such as:
After this PR it raises
The correct behavior as per the API standard is to raise in these cases: https://data-apis.org/array-api/latest/design_topics/lazy_eager.html
There is still surprising behavior with (in)equality checks, but we can't do anything about those as they are needed for Python hashing behavior. The default is
x == y: True if x is y else False
Related to #1189
📚 Documentation preview 📚: https://pytensor--1190.org.readthedocs.build/en/1190/